﻿using Qting.SPI.Serialize;
using System;
using System.Collections.Concurrent;
using System.Windows.Forms;

namespace IPluginInterface
{
    /// <summary>
    /// 注意所有的参数！除了初始化外，params object[] args的第一个参数都是一致的bool类型，表示单双轨道，true表示双轨， false表示单轨
    /// </summary>
    public interface ISpiPlugin: IDisposable
    {
        /// <summary>
        /// 应用程序名称
        /// </summary>
        string Tag { get; }
        /// <summary>
        /// 插件描述说明
        /// </summary>
        string Description { get; }
        /// <summary>
        /// 应用程序版本
        /// </summary>
        Version Version { get; }

        /// <summary>
        /// 插件初始化
        /// </summary>
        /// <returns></returns>
        PluginResult Init(params object[] args);

        /// <summary>
        /// 插件设置，默认打开插件的自有设置窗，配置参数等插件自己保存，提供这个接口，主要是为了在主软件中有入口可以打开插件的设置界面
        /// </summary>
        /// <returns></returns>
        void OpenSettingForm(params object[] args);

        /// <summary>
        /// 开始检测
        /// </summary>
        /// <param name="SpiPcbs">数据类</param>
        /// <param name="bDual">是否单双轨道 true: 双轨 false: 单轨</param>
        /// <param name="args">args附加参数</param>
        /// <returns></returns>
        PluginResult Start(ref SpiPcbs spiPcbs, bool bDual = false, params object[] args);
        /// <summary>
        /// 产品进站前操作
        /// </summary>
        /// <param name="SpiPcbs">数据类</param>
        /// <param name="bDual">是否单双轨道 true: 双轨 false: 单轨</param>
        /// <param name="args">args附加参数</param>
        /// <returns></returns>
        PluginResult BeforeProductIn(ref SpiPcbs spiPcbs, bool bDual = false, params object[] args);
        /// <summary>
        /// 产品进站
        /// </summary>
        /// <param name="SpiPcbs">数据类</param>
        /// <param name="bDual">是否单双轨道 true: 双轨 false: 单轨</param>
        /// <param name="args">args附加参数此处可以读取条码信息等</param>
        /// <returns></returns>
        PluginResult ProductIn(ref SpiPcbs spiPcbs, bool bDual = false, params object[] args);
        /// <summary>
        /// 产品进站后
        /// </summary>
        /// <param name="SpiPcbs">数据类</param>
        /// <param name="bDual">是否单双轨道 true: 双轨 false: 单轨</param>
        /// <param name="args">args附加参数</param>
        /// <returns></returns>
        PluginResult AfterProductIn(ref SpiPcbs spiPcbs, bool bDual = false, params object[] args);
        /// <summary>
        /// 产品出站前
        /// </summary>
        /// <param name="SpiPcbs">数据类</param>
        /// <param name="bDual">是否单双轨道 true: 双轨 false: 单轨</param>
        /// <param name="args">args附加参数</param>
        /// <returns></returns>
        PluginResult BeforeProductOut(ref SpiPcbs spiPcbs, bool bDual = false, params object[] args);
        /// <summary>
        /// 产品出站
        /// </summary>
        /// <param name="SpiPcbs">数据类</param>
        /// <param name="bDual">是否单双轨道 true: 双轨 false: 单轨</param>
        /// <param name="args">args附加参数</param>
        /// <returns></returns>
        PluginResult ProductOut(ref SpiPcbs spiPcbs, bool bDual = false, params object[] args);
        /// <summary>
        /// 产品已经出站
        /// </summary>
        /// <param name="SpiPcbs">数据类</param>
        /// <param name="bDual">是否单双轨道 true: 双轨 false: 单轨</param>
        /// <param name="args">args附加参数</param>
        /// <returns></returns>
        PluginResult AfterProductOut(ref SpiPcbs spiPcbs, bool bDual = false, params object[] args);
        /// <summary>
        /// 流程结束
        /// </summary>
        /// <param name="SpiPcbs">数据类</param>
        /// <param name="bDual">是否单双轨道 true: 双轨 false: 单轨</param>
        /// <param name="args">args附加参数</param>
        /// <returns></returns>
        PluginResult Done(ref SpiPcbs spiPcbs, bool bDual = false, params object[] args);


        /// <summary>
        /// 通用接口
        /// </summary>
        /// <param name="spiPcbs"></param>
        /// <param name="bDual"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        PluginResult YiNing(ref SpiPcbs spiPcbs, params object[] args);
    }
}
